Time-optimal trajectory planning based on event-trigger and conditional proportional control

Trajectory planning is an important issue for manipulators and robots. To get a optimal trajectory, many constraints including actuators specifications, motion range of joints, workspace limitations, etc, and many objectives including the shortest time, the shortest distance, the lowest energy consumption, the minimum oscillations, obstacles-avoiding, etc, should be considered both. In this paper, firstly, the forward kinematics and inverse kinematics of a five axis manipulator are deduced. And, a simple method to choose one appropriate solution from multi solutions of inverse kinematics is proposed. Secondly, an easy-implemented optimization method of trajectory planning is proposed based on seventh order polynomial interpolation, event-trigger mechanism and conditional proportional control (P control). The proposed optimization method can capture the time optimal trajectory, and the actuators specifications including velocity, acceleration of motor can be guaranteed as well. Thirdly, comparative simulations and experiments validate the effectiveness and efficiency of proposed optimization method. The research provides an insight for the application of trajectory optimization on the micro controller with low computing capability and high real-time performance requirement.


Introduction
Trajectory planning is moving from point A to point B while avoiding collisions over time. This can be computed in both discrete and continuous methods. Trajectory planning is a major area in robotics as it gives way to autonomous vehicles [1], gives motion trajectory to manipulators [2] or robots [3]. The goal of trajectory planning is to generate the reference inputs to the motion control system which ensures that the planned trajectories can be executed [4].
Generally, motion planning [5] can be divided into path planning [6] and trajectory planning [7], as shown in Fig 1. The type of trajectory planning contains point-to-point path [8] and continuous path [9,10], and the trajectory planning can be implemented in Cartesian space and joint space. More specifically, trajectory planning is sometimes referred to as motion planning and erroneously as path planning. Trajectory planning is distinct from path planning in that it is parametrized by time. Essentially trajectory planning encompasses path planning in addition to planning how to move based on velocity, time, and kinematics, etc. There are many methods can be utilized to do the trajectory planning. Volkov YS studied the general problem of interpolation by polynomial splines and considered the construction of such splines using the coefficients of expansion of a certain derivative in B-splines. Then, the properties of the obtained systems of equations are analyzed and the interpolation error is estimated [11]. Farid G et al discussed the waypoints-based trajectory generation algorithm specifically for a quadrotor UAV and considers linear interpolation along with parabolic blends to achieve high computational efficiency and continue waypoints [12]. Based on the cubic trigonometric B-spline interpolation algorithm (CTB), Li H et al proposed a new improved method: CTB-EMD, which combines the cubic trigonometric B-spline interpolation algorithm (CTB) and empirical mode decomposition (EMD). In this method, the interpolation curve is more flexible because of the adjustability of shape of the cubic trigonometric B-splines curve. Thus, the overshoot and undershoot problems in the cubic spline interpolation curve can be avoided, and then the decomposition of the signal is more accurate and effect [13]. Fang Y et al proposed a smooth and time-optimal S-curve trajectory planning method to meet the requirements of high-speed and ultra-precision operation for robotic manipulators in modern industrial applications. This method utilizes a piecewise sigmoid function to establish a jerk profile with suitably chosen phase durations such that the generated trajectories are infinitely continuously differentiable under the given constraints on velocity, acceleration and jerk [14].
Among the above methods, the most commonly used is polynomial spline interpolation. However, the generated trajectory planning will be various if different order of polynomial in the

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control spline interpolation is used. To solve this problem, many kinds of optimization methods of trajectory planning are investigated. Ju H et al proposed a time-optimal 3-5-3 polynomial interpolation trajectory planning algorithm based on Genetic Algorithm(GA) according to the velocity limitation of manipulator [15]. Liu Y et al presented a new method of online planning high smooth and time-optimal trajectory for robotic manipulators that applies an adaptive elite genetic algorithm with singularity avoidance (AEGA-SA) [16]. Fu R et al proposed a time-optimal 3-5-3 polynomial interpolation trajectory planning algorithm based on particle swarm optimization (PSO) according to the kinematic constraints of manipulator. The algorithm solves the problem that polynomial interpolation based trajectory planning is hard to be optimized by traditional optimization methods for its shortcomings of high order and lack of convex hull property, etc [17]. Yu L et al presented a general method for the trajectory planning of the redundant planar manipulator. The new application of knot points in the quintic B-spline curve is introduced to generate inverse solutions of class I redundant joints and the particle swarm optimization algorithm is extended to generate solutions of class II redundant joints [18]. Barnett E et al introduced a novel technique, called the bisection algorithm (BA), which is fully implemented in C++ and extends dynamic programming approaches to the problem. This approach is made feasible through careful control of the numerical integration process and the use of a bisection algorithm to resolve constraint violations during integration [19]. Guo H et al presented a simultaneous trajectory planning and tracking controller for use under cruise conditions based on a model predictive control (MPC) approach to address obstacle avoidance for an intelligent vehicle [20].
To get a optimal trajectory, many constraints including actuators specifications (kinematics and dynamics) [21,22], motion range of joints, workspace limitations, etc and many objectives including the shortest time, the shortest distance, the lowest energy consumption, the minimum oscillations [23], obstacles-avoiding [24], etc, should be considered both. Ma J et al reported on a bounded control law for nonholonomic systems of unicycle-type that satisfactorily drive a vehicle along a desired trajectory while guaranteeing a minimum safe distance from another vehicle or obstacle at all times. The control law is comprised of two parts. The first is a trajectory tracking and set-point stabilization control law that accounts for the vehicle's kinematic and dynamic constraints (i.e. restrictions on velocity and acceleration), and the second part is a real-time avoidance control law that guarantees collision-free transit for the vehicle in noncooperative and cooperative scenarios independently of bounded uncertainties and errors in the obstacles' detection process [25]. Wang H et al proposed a smooth point-topoint trajectory planning method for industrial robots. In the accelerated part and decelerated part, the acceleration is planned with fourth-order polynomial formed with the property of the root multiplicity. Then near time-optimal trajectory can be obtained by maximizing the constant velocity part under kinematical constraints [26]. Rodríguez-Seda EJ et al described a new convex optimization (CO) approach to time-optimal trajectory planning (TOTP), which considers both torque and jerk limits. The key insight of the approach is that the non-convex jerk limits are transformed to linear acceleration constraints and indirectly introduced into CO as the linear acceleration constraints [22]. Hsu Y et al proposed a reinforcement learning approach of collision avoidance and investigate optimal trajectory planning for unmanned aerial vehicle (UAV) communication networks [27]. Wang W et al presented an improved artificial potential field method of trajectory planning and obstacle avoidance for redundant manipulators. The method not only focused on the position for the manipulator end-effectors but also considered their posture in the course of trajectory planning and obstacle avoidance [28]. Zhang Z et al presented a hierarchical three-layer trajectory planning framework to realize real-time collision avoidance under complex driving conditions. This is mainly ascribed to the generation of a collision-free trajectory cluster based on the speed and the path re-planning [29]. Wang C et al proposed an enabling motion planning method for post-impact situations by combining the polynomial curve and artificial potential field while considering obstacle avoidance. Then, a hierarchical controller that consists of an upper (a time-varying linear quadratic regulator) and a lower (a nonlinear-optimization-based torque allocation algorithm) controller is developed to track the planned motion [26].
Specially, time-optimal trajectory planning is a more common optimization type. Reiter A et al addressed a time-optimal path following along a predefined end-effector path for kinematically redundant robots, where nonredundant robots are included as special cases [30]. Lu L et al reported a time-optimal motion planning method for robotic machining of sculptured surfaces. As there are high requirements for tool path following accuracy, an efficient numerical integration method based on the Pontryagin maximum principle is adopted as the solver for the time-optimal tool motion planning problem in robotic machining [31]. Xidias EK et al proposed a novel approach based on Genetic Algorithm for time-optimal trajectory planning of a hyper-redundant manipulator which is requested to move from an initial configuration to a final configuration in 3D workspaces considering simultaneously the kinematical constraints of the manipulator (specifically velocity and acceleration) and the presence of obstacles [32].
And, real-time trajectory planning has been a research hotspot so far due to its superior dynamic adaptability [33]. Kim J et al presented a novel trajectory planning approach suitable for online industrial robot applications along short path segments such as spot-welding. The proposed method generates trajectories that are computationally efficient, dynamically near time-optimal, and maintain path-following integrity in high-frequency planning-and-control cycles [9]. Chai R et al developed a two-step strategy for real-time trajectory planning of a hypersonic vehicle (HV) in the reentry phase. The first step generates the optimal trajectory for the HV using a recently proposed fuzzy multiobjective transcription method. In the second step, the optimally generated trajectories are utilized to train a deep neural network (DNN), which is then acted as the optimal command generator in real time [33].
However, most of optimization methods of trajectory planning are based on iterative principle. That means it will cost many time in the optimization process and the optimization will cost lots of capacity of calculation of controller as well. The problem limits the application of these iterative optimization methods on some controller with low computing capability or some scenarios with real-time requirements [16]. Therefore, an easy-implemented optimization method of trajectory planning based on event-trigger and conditional P control is proposed to address the issue, where P control is short for proportional control, which comes from PID control (Proportional-Integral-Derivative control) [34] and conditional means that P control works when some conditions are satisfied. As for event-trigger, Liu J et al proposed an event-triggered vehicle-following control scheme for connected and automated vehicles (CAVs) considering nonideal Vehicle-to-Vehicle communications such as communication delays and packet dropouts. An output-based event-triggered mechanism is employed for reducing computational burden. An Event-Triggered Model Predictive Control (ETMPC) is proposed by combining with a multi-target controller for the lateral and longitudinal vehiclefollowing control of CAVs [35]. Ding X et al proposed an enabling event-triggered sideslip angle estimator by using the kinematic information from a low-cost global positioning system (GPS) and an on-board inertial measurement unit (IMU) [36].
The paper is organized as follows. In Section 2, the system model of a five axis manipulator are analyzed. In Section 3, an easy-implemented optimization method of trajectory planning is proposed based on seventh order polynomial interpolation, event-trigger mechanism and conditional P control. In Section 4, comparative simulations and experiments are implemented to validate the effectiveness and efficiency of proposed optimization method. In Section 5, conclusions are drawn and future works are issued. In Appendix A and Appendix B, the forward kinematics and inverse kinematics of a five axis manipulator are deduced, respectively. In Appendix C gives out why the planning time can be used to adjust the maximum values of planning velocity and acceleration. In Appendix D gives out why the P control could guarantee the stability of time optimal controller and the converge of optimization.

Model
The research subject: a 6 degrees of freedom (DoFs) manipulator with 5 axis and its corresponding system model are shown in Fig 2 and 2 Table 1. The detailed forward kinematics and inverse kinematics are given out in the Appendices A and B, respectively. Specially, the forward kinematics is unique, while there are eight solutions of inverse kinematics.

Trajectory planning based on polynomial interpolation
Take the trajectory planning of point-to-point path in Cartesian space as an example, the trajectory planning based on fifth order polynomial interpolation can be employed to satisfy the six constrains, that is, the position, velocity and acceleration of end effector of manipulator at the start knot point and final knot point are all should be zero and differentiable (they can be non-zero in continuous path). The trajectory planning based on fifth order polynomial interpolation only can get continuous position and velocity from start knot point to final knot point. In order to make the acceleration continuous and differentiable as well to avoid the oscillations caused by sudden accelerations when the manipulator starts and stops, the trajectory planning based on seventh order polynomial interpolation can be utilized to address the issue if the jerk at the start knot point and final knot point are both constrained to be zero.
The trajectory planning based on seventh order polynomial interpolation can be written as where p; _ p; € p; ⃛ p are the position, velocity, acceleration and jerk of end effector of manipulator, respectively. c i , i = 0, . . ., 7 are the coefficients of the seventh order polynomial.

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control Then the constraint conditions, i.e. the position, velocity, acceleration and jerk of end effector of manipulator at the start knot point p 0 and final knot point p 0 are respectively where t 0 , t f are the known time passing through the start knot point and final knot point, respectively. The subscript {0, f} represent the known variables at the start knot point and final knot point, respectively. Specially, Substituting (2) into (1), the coefficients of the seventh order polynomial can be obtained as As thus, the trajectory planning of point-to-point path in Cartesian space with constrains, specifying that the position, velocity, acceleration and jerk of end effector of manipulator at the start knot point and final knot point are continuous from zero, is handled. However, the obtained trajectory is not optimal since the planning time is pre-set and it can be optimized.

Trajectory optimization
After trajectory planning, there are two steps to achieve the trajectory Optimization. The first step is to obtain one appropriate solution of inverse kinematics from the eight calculating solutions Eqs (19), (20) and (23)-(25) based on the current configuration/pose of manipulator. The second step is to seek for the optimal planning time satisfying the actuators specifications including velocity, acceleration of motor.

Appropriate solution of inverse kinematics.
In the first step, the real-time joint angles y ¼ y 1 y 2 y 3 y 4 y 5 � ½ can be measured by sensors firstly. Then the position and attitude parameters p ¼ x y z a b g � ½ of end effector of manipulator can be obtained by forward kinematics Eqs (8)- (11). By using i-th i = 1, (i 2 [1,8]) solution of inverse kinematics, the corresponding joint angles are If the difference between the actual angles θ and the calculating angles θ i through forward and inverse kinematics satisfies where ε θ is the self-determined angle margin to distinguish the appropriate solution of inverse kinematics from the eight calculating solutions Eqs (19), (20) and (23)-(25), then the i-th solution of inverse kinematics is the appropriate solution.

Event-trigger mechanism.
The trajectory planning Eq (1) should guarantee the planning velocity and acceleration are respectively within the maximum velocity and acceleration of actuators specifications. Compare the maximum values of planning velocity and acceleration with the maximum velocity and acceleration of actuators specifications, respectively, 5 events can be obtained as follows.
Event 1: The maximum value of planning velocity is smaller than the maximum velocity of actuators specifications and the maximum value of planning acceleration is smaller than the maximum acceleration of actuators specifications. In this event, the trajectory planning Eq (1) should be adjusted to increase the maximum value of planning velocity until it reaches to its corresponding maximum velocity of actuators specifications, or to increase the maximum value of planning acceleration until it reaches to its corresponding maximum acceleration of actuators specifications. Noting that the maximum values of planning velocity and acceleration cannot reach to their corresponding maximum velocity and acceleration of actuators specifications simultaneously. Event 2: The maximum value of planning velocity is larger than the maximum velocity of actuators specifications, while the maximum value of planning acceleration is smaller than the maximum acceleration of actuators specifications. In this event, the trajectory planning Eq (1) should be adjusted to decrease the maximum value of planning velocity until it reaches to its maximum value of actuators specifications. The maximum value of planning acceleration can not be taken into consideration since it is in its maximum values of actuators specifications. Event 3: The maximum value of planning velocity is smaller than the maximum velocity of actuators specifications, while the maximum value of planning acceleration is larger than the maximum acceleration of actuators specifications. In this event, the trajectory planning Eq (1) should be adjusted to decrease the maximum value of planning acceleration until it reaches to its maximum value of actuators specifications. The maximum value of planning velocity can not be taken into consideration since it is in its maximum values of actuators specifications.

Event 4:
The maximum values of planning velocity and acceleration are both larger than the maximum velocity and acceleration of actuators specifications. In this event, the trajectory planning Eq (1) should be adjusted to decrease the maximum values of planning velocity and acceleration until one of them reaches to its maximum value of actuators specifications and the other is smaller than its maximum value of actuators specifications, or both of them reaches to their related maximum values of actuators specifications at the same time.
Event 5: The maximum values of planning velocity and acceleration are both at the maximum velocity and acceleration of actuators specifications, or one of them at its maximum value of actuators specifications. In this event, nothing should be done since the adjustment of trajectory planning Eq (1) will affect the maximum values of planning velocity and acceleration simultaneously.
It is easy to find that the adjustment of trajectory planning Eq (1) is event-based, and the event-trigger mechanism is clear.

3.2.3
Time optimal controller based on conditional P control. Before designing the time optimal controller, two problems should be clear: 1) which element can be used to adjust the maximum values of planning velocity and acceleration efficiently (what is the control input); and 2) how to use the element to do the adjustment (how to set the control law). To handle these two issues, two theorems are given out as follows.
Theorem 1: In the point to point trajectory planing based on polynomial interpolation, the planning time is in inverse proportion to the maximum velocity and acceleration of planning trajectory.
Theorem 2: Taking the zero errors between the maximum values of planning velocity and acceleration and the maximum velocity and acceleration of actuators specifications as the control and optimization objective, the P control could guarantee the stability of time optimal controller and the converge of optimization.
The proofs of Theorem 1 and Theorem 1 are given out in the Appendices C and D, respectively.
Based on the event-trigger mechanism, the detailed time optimal controller for every event can be rewritten as where TOC1, TOC2, TOC3, TOC4, OPT are the corresponding control laws of Event1, Event2, Event3, Event4, Event5, respectively. T opt is the optimal planning time. k_ y ; k€ y are the tuning parameters of errors of velocity and acceleration in the time optimal controller, respectively. _ y max ; € y max are the maximum velocity and acceleration of actuators specifications, respectively.
Specially, _ y max ; € y max can be individual maximum velocity and acceleration of actuators specifications for individual axis/joint.
Actually, there exist two cases in the second step. They can be concluded as follows. Case 1: The planning velocity _ y and acceleration € y are both in the actuators specifications. In this case, however, the planning time may be not optimal, it could be too long. As thus, the planning time T = t f − t 0 can be decreased to close to the optimal planning time and the actuators specifications are satisfied simultaneously. This case only contains Event 1.
Case 2: The planning velocity _ y or acceleration € y is larger than that the actuators can provide. In this case, the simplest way to solve the problem is increasing the planning time T = t f − t 0 . This case contains Event 2, 3, 4.
Event 5 is the end of time optimal controller and the optimal planning time T opt will be obtained. To avoid the overshoot of the adjustment of trajectory planning Eq (1) based on P control, Case 1 should be set/judged before Case 2.
Based on the five events and two cases, in order to achieve the whole time optimal controller without using iterative algorithms, an easy-implemented optimization method for planning time T = t f − t 0 is proposed as where if the inequality in brackets holds, it is 1, otherwise it is 0. Remark: Under ideal conditions, the planning velocity and acceleration equal to the maximum velocity and acceleration of actuators specifications, respectively, that is, _ y ¼ _ y max and € y ¼ € y max with the optimal planning time T = t f − t 0 . It can be found that the time optimal controller Eq (6) is similar to P control in PID controller [34] and the P control is conditional. Whether P control is activated depends on whether the corresponding actuators specification is satisfied. That is why it is called conditional P control. Here, k_ y ; k€ y are similar to the proportional coefficient in PID control. Besides, other constrains contain: maximum jerk [37], kinematic and dynamic requirements, also can be considered into the right side of Eq (6). And, the optimal planning time in Eq (6) can be discretized to make it available to be used directly in practical applications. The resolution of the optimal planning time T can be the same as the servo control cycle ΔT = 0.001s.
When the optimal planning time T = t f − t 0 is determined, the optimized trajectory for end effector of manipulator p; _ p; € p; p ⃛ and joint angles y; _ y; € y; y ⃛ can be output both for control.

Control scheme
The whole control scheme of trajectory optimization is shown in Fig 3. The control scheme contains three parts. The first part is a trajectory planning based on polynomial interpolation and it is similar to the research subject. The second part is an event-trigger module and it is similar to the feedback loop. The third part is a time optimal controller based on P control. The three parts form a closed loop to search for the optimal planning time and there is no input essentially.

Flow chart
Based on the proposed optimization method of trajectory planning, the program flow chart is shown in Fig 4. The program flow chart contains two blocks that are consistent with the two steps in trajectory optimization. The first block is to choose the appropriate solution for inverse kinematics, and the second block considering two cases is to search for the optimal planning time within actuators specifications. The P-like control algorithm has more concise and efficient structure without considering complicated iterative process. Therefore, it can be easily implemented on micro controller unit with low computing capability.

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control

Simulations
To validate the effectiveness and efficiency of proposed optimization method, comparative simulations are implemented. The simulation parameters are shown in Table 2. The simulation sets of point to point trajectory planning [21] are shown in Table 3. Specially, the actuators specifications including the limitations of velocity and acceleration of motor and they are

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control  Table 3. Simulation sets.

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control € y max ¼ 0:08rad=s 2 and _ y max ¼ 0:12rad=s, respectively. And the limitations are for inputs of joints so that the actuator may contain a reducer.
The trajectory planning results of Simulation 1�6 are shown in Figs 5�10, respectively. The comparisons of simulations in Figs 5�10 are shown in Table 4.

PLOS ONE
Comparing Simulations 1, 2 & 5, it can be found that the maximums of joint angular accelerations are all inside the required angular acceleration of actuators specifications € y max ¼ 0:08rad=s 2 . It means the P control of k€ y in Eq (6) does not work in the three simulations.
In Simulation 1, the maximum of joint angular velocity max fj _ yjg ¼ 0:1636rad=s is larger than

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control the required angular velocity of actuators specifications _ y max ¼ 0:12rad=s. In Simulation 2, the maximum of joint angular velocity max fj _ yjg ¼ 0:0818rad=s is smaller than the required angular velocity of actuators specifications _ y max ¼ 0:12rad=s. In Simulation 5 based on the proposed optimization method, the maximum of joint angular velocity max fj _ yjg ¼ 0:12rad=s just equal

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control to the required angular velocity of actuators specifications _ y max ¼ 0:12rad=s. That means the planning time should be increased in Simulation 1 and decreased in Simulation 2 to make time optimal and make actuators specifications satisfied, which is achieved by the time optimal controller Eq (6). Noting that the main effector is the maximum of joint angular velocity max fj _ yjg.

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control Comparing Simulations 3, 4 & 6, it can be found that the maximum of joint angular velocity in Simulation 4 max fj _ yjg ¼ 0:0954rad=s is inside the required angular velocity of actuators specifications _ y max ¼ 0:12rad=s, while the maximum of joint angular velocity in Simulation 3 max fj _ yjg ¼ 0:1909rad=s is not. It means the P control of k_ y in Eq (6) does not work in

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control Simulations 4, and the P control of k_ y in Eq (6) does work at the start of optimizations and does not work at the end of optimizations in Simulation 3, and only the P control of k€ y in Eq (6) does work at the end of optimizations in Simulation 3. In Simulation 3, the maximum of joint angular acceleration max fj € yjg ¼ 0:0656rad=s 2 is larger than the required angular

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control acceleration of actuators specifications € y max ¼ 0:02rad=s 2 . In Simulation 4, the maximum of joint angular acceleration max fj € yjg ¼ 0:0164rad=s 2 is smaller than the required angular acceleration of actuators specifications € y max ¼ 0:02rad=s 2 . In Simulation 6 based on the proposed optimization method, the maximum of joint angular acceleration max fj € yjg ¼ 0:02rad=s just equal to the required angular acceleration of actuators specifications € y max ¼ 0:02rad=s 2 . That means the planning time should be increased in Simulation 3 and decreased in Simulation 4 to make time optimal and make actuators specifications satisfied, which is achieved by the time optimal controller Eq (6) as well. Noting that the main effector is the maximum of joint angular acceleration max fj € yjg. Comparing Simulations 1 & 2 with 3, 4, 5 & 6, it can be found that the trajectory planning based on seventh order polynomial interpolation can guarantee the planning jerk smooth and stable [37], but the trajectory planning based on fifth order polynomial interpolation cannot. Both of them can generate the continuous acceleration profile. Comparing Simulations 1 & 3 and Comparing Simulations 2 & 4, it can be found that the trajectory planning based on seventh order polynomial interpolation has higher maximum of joint angular velocity max fj _ yjg and higher maximum of joint angular acceleration max fj € yjg than that of the trajectory planning based on fifth order polynomial interpolation. That's the trade-off.
Simulation 5 is the optimization results of Simulation 1 & 2, and Simulation 6 is the optimization results of Simulation 3 & 4. In Simulation 5, the optimization process of planning time T = t f − t 0 with initial value in Simulation 1 (T = t f − t 0 = 10s) and Simulation 2 (T = t f − t 0 = 20s) are shown in Fig 11. In Simulation 6, the optimization process of planning time T = t f − t 0  with initial value in Simulation 3 (T = t f − t 0 = 10s) and Simulation 4 (T = t f − t 0 = 20s) are shown in Fig 12. Actually, in Figs 11(b) and 12(b), the decreasing curve represents Case 1 and the planning time should be decreased to close to the optimal planning time, while the increasing curve in Figs 11 and 12 represents Case 2 and the planning time should be increased to close to the optimal planning time. Finally, the planning time is optimized as 15.908s in Simulation 5 and 18.106s in Simulation 6. Meanwhile, the actuators specifications are satisfied. It can be shown that, the optimizing loops are less than 10, which shows the trajectory optimization can be finished quickly. Noting that there exists an overshoot in the decreasing curve. The phenomenon is similar to P control in PID control.
To evaluate the performance of calculation efficiency of proposed optimization method, comparative simulations based on Simulation 5 are implemented with two iterative algorithms: GA [15] and PSO [17], and one hierarchical three-layer trajectory planning framework [29]. Compared with these two algorithms, the required time for trajectory optimization based on the proposed optimization method is much lower, which is about 19ms, while the GA and PSO algorithms would cost about 1326ms and 1764ms, respectively, and the hierarchical three-layer trajectory planning framework would cost about 42ms. Noting that the required time is the calculated time of PC to get the optimized trajectory, instead of the planning time. And, the proposed method combining event-trigger and conditional P control, GA, PSO and the hierarchical three-layer trajectory planning framework are employed to achieve the timeoptimal trajectory planning individually. Therefore, the proposed optimization method owns higher efficiency of trajectory optimization. The planning trajectory based on the proposed optimization method in Simulation 5 can be drawn by Robotics Toolbox in Matlab, as shown in Fig 13, where the blue curve is the planning trajectory.

Experiments
The experimental platform, a manipulator, is shown in Fig 2a, and its system parameters are the same as simulation parameters Table 2. The maximum velocity and acceleration of actuators specifications of each joint of manipulator are shown in Table 5. The proposed optimization method is employed to do the trajectory planning: repeating the point to point trajectory The trajectory planning can be divided into three point to point movements:

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control The trajectory planning results of experiment based on the proposed optimization method is shown in Fig 14. Some of experimental results are also shown in Table 5. In the initial panning time T = t f = 3s of every point to point movement without optimization, the maximum values of planning velocity and acceleration should be both smaller than the maximum velocity and acceleration of actuators specifications in each joints (Event 1), which means the panning time T = t f = 3s can be smaller to make the manipulator move faster and the actuators specifications can be satisfied simultaneously. In the optimal panning time with the proposed optimization method, the optimized planning time of p A ! p B , p B ! p C , p C ! p D are 1.537s, 1.494s, 1.537s, respectively. And the maximums of joint angular velocities max fj _ yjg ¼ 8:9342rad=s are all inside the required angular velocities of actuators specifications € y max ¼ 12rad=s (see Fig   14(d)), while the maximums of joint angular accelerations max fj _ yjg ¼ 20rad=s 2 just equal to the required angular accelerations of actuators specifications _ y max ¼ 20rad=s 2 (see Fig 14(e)). As thus, the planning times of three point to point movements all reach their optimal values.
The optimization process of planning time T = t f − t 0 with initial value 3s of three point to point movements are shown in Fig 15. The decreasing curve represents Case 1 and the planning time should be decreased to close to the optimal planning time, while the increasing curve represents Case 2 and the planning time should be increased to close to the optimal planning time. Finally, the planning times of three movements of point to point are respectively optimized as 1.537s, 1.494s, 1.537s. Meanwhile, the actuators specifications are satisfied. It can be shown that, the optimizing loops are less than 10, which shows the trajectory optimization can be finished quickly. It makes room for the applications of proposed trajectory optimization on the micro controller with low computing capability and high real-time performance requirement.

Conclusions
A method of time-optimal trajectory planning based on polynomial interpolation, event-trigger mechanism and conditional P control is proposed in this paper. The main contributions can be concluded as follows:

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control • The forward kinematics and inverse kinematics of a five axis manipulator are deduced. And, a simple method to choose one appropriate solution from multi solutions of inverse kinematics is proposed.
• Based on seventh order polynomial interpolation, event-trigger mechanism and conditional P control, an easy-implemented optimization method of trajectory planning is proposed to guarantee that the obtained trajectory is time optimal and satisfies actuators specifications.
• The effectiveness and efficiency of proposed optimization method are validated by comparative simulations and experiments.

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control Future work will focus on easy-implemented optimization method of trajectory planning with more constraints and objectives. where, n x ¼ cos y 1 cosðy 2 þ y 3 þ y 4 Þcos y 5 À sin y 1 sin y 5 o x ¼ À cos y 1 cosðy 2 þ y 3 þ y 4 Þsin y 5 À cos y 5 sin y 1 a x ¼ À cos y 1 sinðy 2 þ y 3 þ y 4 Þ 8 > > > < > > > : ; n y ¼ cosðy 2 þ y 3 þ y 4 Þcos y 5 sin y 1 þ cos y 1 sin y 5 o y ¼ cos y 1 cos y 5 À cosðy 2 þ y 3 þ y 4 Þsin y 1 sin y 5 a y ¼ À sin y 1 sinðy 2 þ y 3 þ y 4 Þ 8 > > > < > > > : ; ; Set the coordinate system {0} in the first axis as the base/reference coordinate system of manipulator, then the pose transformation matrix from the end effector to the base is shown in (9). In the forward kinematics, the position parameters x, y, z and attitude parameters α, β, γ of the end effector are dependent variables, while the joint angles θ i (i = 1, 2, 3, 4, 5) are independent variables. According to the chain rule, the forward kinematics and its analytical solutions of the manipulator can be directly obtained as shown in (9), where p x p y p z � � T are the parameters x, y, z of end effector of manipulator on the base coordinate system {0}, that is ; a x a y a z � � T are the attitude related parameters of end effector of manipulator on the base coordinate system {0}. Based on the rotation order: Z-Y-X, the attitude parameters (Euler angles) α, β, γ can be obtained as ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffiffi where arctan2(Y, X) is a C function, which returns the arctangent of Y/X in radians. The sign of the values of Y and X determines the correct quadrant.

B Inverse kinematics
In the inverse kinematics, the joint angles θ i (i = 1, 2, 3, 4, 5) are dependent variables, while the position parameters x, y, z and attitude parameters α, β, γ of end effector of manipulator are independent variables. Because the end effector of 5 axis manipulator has only 5 DoFs in Cartesian space, only 5 parameters of manipulator (3 position parameters and 2 attitude parameters) can be determined by given 5 joint angles. And the last one attitude parameter is not an independent variable, which can be calculated via the forward kinematics Eqs (8)- (11). Set the five parameters of manipulator: position parameters p x , p y , p z , the rotation angle α around x 0 axis and β around y 0 axis in the base coordinate system {0} can be determined by joint angles θ i (i = 1, 2, 3, 4, 5), then the rotation angle γ around z 0 axis in the base coordinate system {0} is the non-independent variable, which can be calculated via the forward kinematics Eqs (8)- (11). Thus, given five parameters p x p y p z a b � � of manipulator, the five joint angles θ i (i = 1, 2, 3, 4, 5) can be deduced as follows.

C Proof of Theorem 1
In the point to point trajectory planing based on polynomial interpolation, the planning time is in inverse proportion to the maximum velocity of planning trajectory. From common sense, since the distance between start knot and final knot is constant, if the planning time increases, then the average velocity and maximum velocity will decrease generally.
In theory, take a point to point trajectory planing based on third order polynomial interpolation as an example, and assume that there are two planning time (t 1 , t 2 and t 1 < t 2 ) for the given trajectory, then the maximum velocity with planning time t 1 is larger than that with planning time t 2 .
To prove it, the detailed geometric description can be shown in Fig 16, where, v 1 = b 10 + b 11 t + b 12 t 2 and v 2 = b 20 + b 21 t + b 22 t 2 are the velocities of trajectory planing based on third order polynomial interpolation with planning time t 1 and t 2 , respectively, v 1max , v 2max are the maximum velocities of v 1 , v 2 , respectively, S 1 , S 2 are the enclosure areas between the horizontal axis T and curves v 1 , v 2 , respectively, which both represent the constant distance between start knot and final knot.
As thus, the proposition can be set as follow.
In the point to point trajectory planing based on third order polynomial interpolation, if t 1 < t 2 , then v 1 max > v 2 max . Proof: Assume that t 2 = λt 1 , λ > 1. Since S 1 = S 2 , then it yields From the 16, the maximum values of v 1 , v 2 can be respectively written as https://doi.org/10.1371/journal.pone.0273640.g016

PLOS ONE
Time-optimal trajectory planning based on event-trigger and conditional P control Combining (26) and (27) Since t 2 = λt 1 , λ > 1, then v 1 max > v 2 max . The trajectory planing based on other n-th order, including the seventh order polynomial interpolation, can be analyzed in the same way and the same conclusion can be obtained.

D Proof of Theorem 2
Assume that the system state equation can be written as where x 1 donates the maximum velocity of trajectory planning. For the system, the desired output is x 1d , which is the same as maximum velocity of actuator specifications, and u(T) is the control input with respect to planning time T. The control objective is to obtain an optimal planning time T opt to make the maximum velocity of trajectory planning equal to the maximum velocity of actuator specifications.
Set the error between the maximum velocity of trajectory planning and the maximum velocity of actuator specifications as then it yields Let the nonnegative Lyapunov function as then combining Eqs (29) and (31) yields Since _ x 1d ¼ 0, then the control input can be written in P control form as where k p is the coefficient of P control. And then, Therefore, the P control could guarantee the stability of time optimal controller and the converge of optimization. The maximum acceleration term in the conditional P control Eq (6) can be deduced in the same way. By adding the event-trigger, this is the reason why condition P control is employed.